#ifndef SERIAL_WIDGET_H
#define SERIAL_WIDGET_H

#include <QWidget>
#include <QSerialPort>
#include <QEvent>
#include <QFileDialog>
#include <QFile>
#include <QMessageBox>
namespace Ui {
class SerialWidget;
}

class SerialWidget : public QWidget
{
    Q_OBJECT

public:
    explicit SerialWidget(QWidget *parent = nullptr);
    ~SerialWidget();
    void setSerialPort(QSerialPort* serialPort);
    QSerialPort* serialPort(){
        return this->m_serialPort;
    }
private:
    void send();
protected:
    bool eventFilter(QObject *object, QEvent *event);

private slots:
    void on_pushButton_send_clicked();

    void on_pushButton_disconnect_clicked();

    void on_pushButton_save_to_file_clicked();

    void on_checkBox_recv_to_file_stateChanged(int arg1);

private:
    Ui::SerialWidget *ui;
    QSerialPort* m_serialPort;
    QFile* recv_file;
};

#endif // SERIAL_WIDGET_H
